
CREATE  function dbo.f_finsublen()
returns 
   @sublentable table
    (
        sc1len integer,
        sc2len integer,
        sc3len integer,
        sc4len integer,
        sc5len integer,
        sc6len integer,
        sc7len integer,
        sc8len integer,
        sc9len integer,
        sc10len integer
    )
   
as  

begin

  declare @sc1len integer
  declare @sc2len integer
  declare @sc3len integer
  declare @sc4len integer
  declare @sc5len integer
  declare @sc6len integer
  declare @sc7len integer
  declare @sc8len integer
  declare @sc9len integer
  declare @sc10len integer
  select @sc1len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen1'
  select @sc2len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen2'
  select @sc3len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen3'
  select @sc4len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen4'
  select @sc5len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen5'
  select @sc6len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen6'
  select @sc7len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen7'
  select @sc8len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen8'
  select @sc9len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen9'
  select @sc10len=cast (p_paramvalue as integer) from ts_parameters
    where p_paramnm='sublen10'
    
  set @sc2len=@sc2len+@sc1len
  set @sc3len=@sc3len+@sc2len
  set @sc4len=@sc4len+@sc3len
  set @sc5len=@sc5len+@sc4len
  set @sc6len=@sc6len+@sc5len
  set @sc7len=@sc7len+@sc6len
  set @sc8len=@sc8len+@sc7len
  set @sc9len=@sc9len+@sc8len
  set @sc10len=@sc10len+@sc9len

  insert into @sublentable values(@sc1len,@sc2len,@sc3len,@sc4len,@sc5len
    ,@sc6len,@sc7len,@sc8len,@sc9len,@sc10len)
  return

end




